<?php

class UsersController extends FormController
{

  protected function initialize()
  {
    parent::initialize();

    $groups = new FormElement_AjaxCheckboxes('user_id', 'Groups');
    $groups->table = 'acl_groups';
    $groups->keyField = 'group_id';
    $groups->labelField = 'group_name';
    $groups->assocTable = 'acl_groups_users';

    $permissions = new FormElement_AjaxCheckboxes('user_id', 'Permissions');
    $permissions->table = 'acl_permissions';
    $permissions->keyField = 'permission_id';
    $permissions->labelField = 'permission_name';
    $permissions->assocTable = 'acl_permissions_users';

    $this->Form->addElement(new FormElement_Text('user_email', 'Email'));
    $this->Form->addElement($groups, Form::ACTION_INDEX | Form::ACTION_EDIT);
    $this->Form->addElement($permissions, Form::ACTION_INDEX | Form::ACTION_EDIT);
  }

}
